import { faker } from "@faker-js/faker";
import { createFileRoute } from "@tanstack/react-router";
import { IssuesTable } from "@/components/issues/issues-table";
import { type Issue, issuesColumns } from "../components/issues/issues-columns";

const generateMockIssues = (count: number): Issue[] => {
  return Array.from({ length: count }, () => ({
    id: faker.string.uuid(),
    title: faker.lorem.sentence(5),
    type: faker.helpers.arrayElement(["bug", "script", "env"]),
    owner: faker.person.fullName(),
    test: faker.lorem.sentence(5),
    task: faker.lorem.sentence(3),
    create_at: faker.date.recent({ days: 30 }),
  }));
};

export const Route = createFileRoute("/_app/issues")({
  component: IssuesPage,
});

function IssuesPage() {
  const data = generateMockIssues(2000);
  return <IssuesTable columns={issuesColumns} data={data} />;
}
